package com.electric.electric.serviceimpl;

import com.electric.electric.POJO.Entity.DeviceModel; // 假设您的 DeviceModel 实体类
import com.electric.electric.mapper.DeviceModelMapper;
import com.electric.electric.POJO.VO.DeviceModelVO; // 假设您的 DeviceModelVO 类
import com.electric.electric.service.DeviceModelService; // 假设您有 DeviceModelService 接口
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class DeviceModelServiceImpl implements DeviceModelService {

    @Autowired
    private DeviceModelMapper deviceModelMapper;

    @Override
    public List<DeviceModelVO> getAllDeviceModels() {
        // 获取所有的 DeviceModel 实体
        List<DeviceModel> deviceModels = deviceModelMapper.selectList(); // 传递 null 作为 QueryWrapper 查询所有

        // 使用 mapper 中的 deviceModelToDeviceModelVO 方法进行转换
        return deviceModels.stream()
                .map(deviceModel -> deviceModelMapper.deviceModelToDeviceModelVO(deviceModel.getId())) // 传递 ID
                .collect(Collectors.toList());
    }
    // 您可能还有其他的业务逻辑方法
}